home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 PPC / MkPluginAliases / MkPluginAliases.rsrc / PYC_2558___main__ (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  1996-05-20  |  3.6 KB  |  114 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.3)
  3.  
  4. import sys
  5.  
  6. def help():
  7.     print '\nTry the following:\n1. Remove any old "Python Preferences" files from the system folder.\n2. Remove any old "PythonCore" files from the system folder.\n3. Make sure this script, PythonPPC and PythonCore are all located in the\n   python home folder (where the Lib and PlugIns folders are)\n4. Run this script again, by dropping it on PythonPPC.\n\nIf this fails try removing starting afresh from the distribution archive.\n'
  8.     sys.exit(1)
  9.  
  10.  
  11. try:
  12.     import os
  13. except ImportError:
  14.     print "\nI cannot import the 'os' module, so something is wrong with sys.path\n"
  15.     help()
  16.  
  17.  
  18. try:
  19.     import Res
  20. except ImportError:
  21.     
  22.     try:
  23.         os.chdir(':PlugIns')
  24.     except IOError:
  25.         print "\nI cannot find the 'PlugIns' folder, so I am obviously not run from the Python\nhome folder.\n"
  26.         help()
  27.  
  28.     import imp
  29.     cwd = os.getcwd()
  30.     tblibname = os.path.join(cwd, 'toolboxmodules.slb')
  31.     if not os.path.exists(tblibname):
  32.         print "\nI cannot find the 'toolboxmodules.slb' file in the PlugIns directory.\nStart afresh from a clean distribution. \n"
  33.         sys.exit(1)
  34.     
  35.     
  36.     try:
  37.         for wtd in [
  38.             'Ctl',
  39.             'Dlg',
  40.             'Evt',
  41.             'Qd',
  42.             'Res',
  43.             'Win']:
  44.             imp.load_dynamic(wtd, tblibname)
  45.     except ImportError:
  46.         print '\nI cannot load the toolbox modules by hand. Are you sure you are\nusing a PowerPC mac?\n'
  47.         sys.exit(1)
  48.  
  49.  
  50. import macfs
  51. import EasyDialogs
  52. import macostools
  53. goals = [
  54.     ('mactcp.slb', 'mactcpmodules.slb'),
  55.     ('macdnr.slb', 'mactcpmodules.slb'),
  56.     ('AE.slb', 'toolboxmodules.slb'),
  57.     ('Cm.slb', 'toolboxmodules.slb'),
  58.     ('Ctl.slb', 'toolboxmodules.slb'),
  59.     ('Dlg.slb', 'toolboxmodules.slb'),
  60.     ('Evt.slb', 'toolboxmodules.slb'),
  61.     ('Fm.slb', 'toolboxmodules.slb'),
  62.     ('Menu.slb', 'toolboxmodules.slb'),
  63.     ('List.slb', 'toolboxmodules.slb'),
  64.     ('Qd.slb', 'toolboxmodules.slb'),
  65.     ('Qt.slb', 'toolboxmodules.slb'),
  66.     ('Res.slb', 'toolboxmodules.slb'),
  67.     ('Scrap.slb', 'toolboxmodules.slb'),
  68.     ('Snd.slb', 'toolboxmodules.slb'),
  69.     ('TE.slb', 'toolboxmodules.slb'),
  70.     ('Win.slb', 'toolboxmodules.slb'),
  71.     ('imgcolormap.slb', 'imgmodules.slb'),
  72.     ('imgformat.slb', 'imgmodules.slb'),
  73.     ('imggif.slb', 'imgmodules.slb'),
  74.     ('imgjpeg.slb', 'imgmodules.slb'),
  75.     ('imgop.slb', 'imgmodules.slb'),
  76.     ('imgpbm.slb', 'imgmodules.slb'),
  77.     ('imgpgm.slb', 'imgmodules.slb'),
  78.     ('imgppm.slb', 'imgmodules.slb'),
  79.     ('imgtiff.slb', 'imgmodules.slb'),
  80.     ('imgsgi.slb', 'imgmodules.slb')]
  81.  
  82. def main():
  83.     (dir, ok) = macfs.GetDirectory('Where is the PlugIns folder?')
  84.     if not ok:
  85.         sys.exit(0)
  86.     
  87.     os.chdir(dir.as_pathname())
  88.     if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0:
  89.         sys.exit(0)
  90.     
  91.     LibFiles = []
  92.     allfiles = os.listdir(':')
  93.     for f in allfiles:
  94.         if f[-4:] == '.slb':
  95.             finfo = macfs.FSSpec(f).GetFInfo()
  96.             if finfo.Flags & 32768:
  97.                 os.unlink(f)
  98.             else:
  99.                 LibFiles.append(f)
  100.         
  101.     
  102.     print LibFiles
  103.     if EasyDialogs.AskYesNoCancel('Proceed with creating new ones?') <= 0:
  104.         sys.exit(0)
  105.     
  106.     for dst, src in goals:
  107.         pass
  108.     
  109.     EasyDialogs.Message('All done!')
  110.  
  111. if __name__ == '__main__':
  112.     main()
  113.  
  114.